package com.hrb.commonsdk.mglide;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.GlideModule;
import com.hrb.commonsdk.okhttp.https.HttpsUtils;

import java.io.InputStream;

import okhttp3.OkHttpClient;

/**
 * OKHTTPSGlide加载图片处理的工具类
 */
public class OkHttpGlideModule implements GlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {

    }

    @Override
    public void registerComponents(Context context, Glide glide) {
        OkHttpClient mHttpClient = new OkHttpClient().newBuilder()
                .sslSocketFactory(HttpsUtils.initSSLSocketFactory(),HttpsUtils.initTrustManager())
                //.sslSocketFactory(SSLSocketClient.getSSLSocketFactory())//方法过期了
                .hostnameVerifier(SSLSocketClient.getHostnameVerifier())
                .build();
        glide.register(GlideUrl.class,InputStream.class,new OkHttpUrlLoader.Factory(mHttpClient));

    }
}
